<template>
  <el-table :data="tableList" style="width: 100%">
    <el-table-column prop="deliveryPromptId" label="序号" width="180" />
    <el-table-column prop="earTag" label="种母耳号" width="180" />
    <el-table-column prop="stateDays" label="妊娠天数" />
    <el-table-column prop="buildingName" label="栋舍" />
    <el-table-column prop="columnName" label="栏位" />
    <el-table-column prop="hybridizationDate" label="配种日期" />
    <el-table-column prop="prelaborDate" label="预产日期" />
    <el-table-column prop="Type" label="类型">
      <template #default="scope">
        <span v-if="scope.row.type == 1">警告</span>
        <span v-else>提示</span>
      </template>
    </el-table-column>
  </el-table>

  <el-pagination v-model:current-page="tableData.pageIndex" v-model:page-size="tableData.pageSize"
    :page-sizes="[10, 15, 20, 25]" :background="true" layout="total, sizes, prev, pager, next, jumper"
    :total="page.totalCount" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
</template>

<script setup lang="ts">
import promptlist from '@/api/PromptReport/index'
import { childbirthQuerys } from '@/api/PromptReport/model'


const tableData = reactive<childbirthQuerys>({
  pageIndex: 1,
  pageSize: 10
})
//分页参数
const page = reactive({
  totalCount: 0,
  pageCount: 0
})

//分娩列表方法
const tableList = ref([])
const getchildbitrh = async () => {
  promptlist.getList(tableData)
    .then(res => {
      tableList.value = res.data.data
      page.totalCount = res.data.totalCount
      page.pageCount = res.data.pageCount
    })
    .catch(err => {
      console.log(err)

    })
}

//分页
//分页方法
const handleSizeChange = (val: number) => {
  tableData.pageSize = val
  getchildbitrh();
}
const handleCurrentChange = (val: number) => {
  tableData.pageIndex = val
  getchildbitrh();
}

onMounted(() => {
  getchildbitrh()
})
</script>